package com.shenghui.enterprise.vo;
import java.io.Serializable;

/**
 * @Description: 请求后返回数据的结果集
 * @Author houjh
 * @Email: happyxiaohou@gmail.com
 * @Date: 2020-05-29 9:17
 * @Copyright (c) 2020-2022 云南昇晖科技有限公司
 */
public class Result<E> implements Serializable {

    private static final long serialVersionUID = 6875091239157807583L;

    //返回状态,大于零为正常状态，小于零为非正常状态
    private Integer status;
    //返回信息
    private String message;

    private E object;

    public Result(Integer status, String message) {
        this.status = status;
        this.message = message;
    }

    private Result(Integer status, String message, E obj) {
        this.status = status;
        this.message = message;
        this.object = obj;
    }

    public static Result ok(String message){
        return new Result(1, message);
    }
    public static Result ok(){
        return new Result(1, null);
    }
    public static Result ok(Object object){
        return new Result(1, "", object);
    }
    public static <T> Result ok(String message, T obj){
        return new Result(1, message, obj);
    }
    public static Result error(String message){
        return new Result(-1, message);
    }
    public static <T> Result error(String message, T obj){
        return new Result(-1, message, obj);
    }
    public static Result  info(String message){
        return new Result(0 ,message);
    }
    public static <T> Result info(String message, T obj){
        return new Result(0, message, obj);
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public E getObject() {
        return object;
    }

    public void setObject(E object) {
        this.object = object;
    }
}
